﻿using System;
using System.ComponentModel.Composition;
using Microsoft.Practices.Prism.Regions;
using Microsoft.Practices.Prism;
using System.Windows.Controls;
using BizControl.Presentation.StickyNotesModule.ViewModels;
using System.Windows;

namespace BizControl.Presentation.StickyNotesModule.Views
{
  [Export]
  public partial class StickyNotesView : UserControl
  {
    public StickyNotesView()
    {
      InitializeComponent();
    }

    [ImportingConstructor]
    public StickyNotesView(StickyNotesViewModel viewModel)
      : this()
    {
      this.DataContext = viewModel;
    }

    private void MinimizeButton_Click(object sender, System.Windows.RoutedEventArgs e)
    {
      if (NotesListBox.SelectedIndex >= 0)
        if ((sender as FrameworkElement).DataContext ==((NotesListBox.ItemContainerGenerator.ContainerFromIndex(NotesListBox.SelectedIndex) as ListBoxItem).DataContext))
          NotesListBox.SelectedIndex = -1;
    }
  }
}
